﻿
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>计划运费</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/X-admin/css/font.css" rel="stylesheet" />

    <script src="~/X-admin/lib/layui/layui.all.js"></script>
    <link href="~/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/X-admin/js/jquery.min.js"></script>
    <script src="~/X-admin/js/xadmin.js"></script>
    <script src="~/js/framework/sysframework.js"></script>
    <script src="~/js/framework/commonjs.js"></script>
    <script type="text/html" id="barDemo">
        <a title="查看详情" href="javascript:;" lay-event="view" id="frmView"><i class="layui-icon">&#xe615;</i></a>
               <a title="计划删除" href="javascript:;" lay-event="del" id="frmDel"><i class="layui-icon">&#xe640;</i></a>
    </script>

</head>
<body>
    <div class="layui-fluid" style="width:100%;">
        <div id="bDiv">
        </div>
        <div style="float:left;width:100%;">
            <div class="layui-card">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5" name="qForm" id="qForm">
                            <div class="layui-inline layui-show-xs-block">

                                <input class="layui-input" placeholder="开始日期" autocomplete="off" name="sDate" id="sDate" style="margin-right:15px;">
                            </div>

                            <div class="layui-inline layui-show-xs-block">
                                <input class="layui-input" placeholder="结束日期" name="eDate" id="eDate" autocomplete="off" style="margin-right:15px;">
                            </div>
                            <div class="layui-inline layui-show-xs-block">

                                <input type="text" name="mCode" placeholder="记录编码" autocomplete="off" class="layui-input" id="mCode">
                            </div>
                            <div class="layui-inline layui-show-xs-block">

                                <input class="layui-input" placeholder="U8单据编码" autocomplete="off" name="outOrderCode" id="outOrderCode">
                            </div>
                            <div class="layui-inline layui-show-xs-block">

                                <input class="layui-input" placeholder="客户名称" autocomplete="off" name="cuName" id="cuName">
                            </div>


                        </form>
                    </div>

                    <div class="layui-card-body layui-table-body layui-table-main" id="layui-table-main">
                        <table class="layui-hide" id="list" lay-filter="list"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

</html>

<script>
    var mCodes = "";
    function loadData() {
        layui.use('table', function () {
            var conditon = JSON.stringify(FormToJson("qForm"));
            var table = layui.table;
            table.render({
                elem: '#list'
                , cols: [[ //标题栏
                    { totalRowText: "合计", width: 90 }
                    , { field: 'ftCode', title: 'U8单据号', width: 200 }
                    , { field: 'cuName', title: '客户名称', width: 200 }
                    , { field: 'hDate', title: '发生日期', width: 120 }
                    , { field: 'total', title: '总金额', width: 100, totalRow: true }
                    , { field: 'memo', title: '备注说明', width: 230 }
                    , { field: 'createtime', title: '填单时间', width: 180 }
                    , { field: 'right', title: '操作', toolbar: '#barDemo', width: 70, fixed: 'right' }
                ]], done: function (res, curr, count) {


                }
                // , height: $(document).height() - $('#list').offset().top - 20
                , url: "../Plan/GetDataList?dataType=sflist&condition=" + conditon
                , totalRow: true
                , skin: 'row' //表格风格
                , even: true
                , page: true //是否显示分页
                , limits: [20, 30, 50]
                , limit: 20 //每页默认显示的数量
            });
            //监听工具条
            table.on('tool(list)', function (obj) {
                var data = obj.data;
                if (obj.event == 'view') {
                    InfoOpenPage('../Plan/FreightDetail?ftCode=' + data.ftCode, data.ftCode + "-详情", "80%", "90%");

                } else if (obj.event == 'del') {
                    layer.confirm('确认要删除该数据？', function (index) {
                        var info = DelData(data.ftCode);
                        if (info.result) {
                            layer.msg("删除成功");
                            obj.del();
                        } else {
                            layer.msg(info.message);
                        }
                        layer.close(index);
                    });
                }
            });

    
        });
    }
    $(function () {
        webCode = getUrlVariable("menuCode");
        BannerData(webCode, "bDiv");

        loadData();
    })
    layui.use(['laydate'], function () {
        var $ = layui.$;
        var laydate = layui.laydate;
        var nowTime = new Date().valueOf();
        var max = null;
        var start = laydate.render({
            elem: '#sDate',
            trigger: 'click',
            type: 'datetime',
            format: 'yyyy/MM/dd',
            max: nowTime,
            btns: ['clear', 'confirm'],

            done: function (value, date) {
                endMax = end.config.max;
                end.config.min = date; //最大时间为结束时间的开始值
                end.config.min.month = date.month - 1;
            }
        });
        var end = laydate.render({
            elem: '#eDate',
            trigger: 'click',
            type: 'datetime',
            max: 4073558400000,
            format: 'yyyy/MM/dd',
            done: function (value, date) {
                if ($.trim(value) == '') {
                    var curDate = new Date();
                    date = { 'date': curDate.getDate(), 'month': curDate.getMonth() + 1, 'year': curDate.getFullYear() };
                }
                start.config.max = date;//最小时间为开始时间的最大值
                start.config.max.month = date.month - 1;
            }
        })
    })
    /**
    删除方法
    **/
    function DelData(ftCode) {
        var info = undefined;
        $.ajax({
            url: "../Plan/DelFreightInfo",
            data: { ftCode: ftCode },
            dataType: "json",
            type: "POST",
            async: false,
            success: function (data) {

                info = data;
            }
        });
        return info;
    }

</script>
